package com.share.device.controller;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.device.domain.Region;
import com.share.device.service.IRegionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地区controller
 */
@Tag(name = "地区信息接口管理")
@RestController
@RequestMapping("/region")
public class RegionController extends BaseController {

    @Autowired
    private IRegionService regionService;

    @GetMapping("/treeSelect/{parentCode}")
    @Operation(summary = "根据上级code获取下级数据列表")
    public AjaxResult selectByParentCode(@PathVariable String parentCode){
        log.info("根据上级code获取下级数据列表:{}",parentCode);
        List<Region> regionList = regionService.selectByParentCode(parentCode);
        return AjaxResult.success(regionList);
    }
}
